﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeamCommunitySolution.Domain.DataLayer.Venues;
using TeamCommunitySolution.Domain.DataLayer.Base;
using TeamCommunitySolution.Domain.DataLayer.Leagues;
using System.Web.Security;

namespace TeamCommunitySolution.Services.Services {
  public interface IApplicationService {
    // <summary>
    /// Creates the venue.
    /// </summary>
    /// <param name="venue">The venue.</param>
    /// <param name="owner">The owner.</param>
    void VenueCreate(Venue venue, SystemUser owner);

    /// <summary>
    /// Updates the venue.
    /// </summary>
    /// <param name="venue">The venue.</param>
    void VenueUpdate(Venue venue);

    /// <summary>
    /// Removes the venue.
    /// </summary>
    /// <param name="id">The venue id.</param>
    void VenueRemove(string id);

    /// <summary>
    /// Gets the venue.
    /// </summary>
    /// <param name="id">The of the venue id.</param>
    /// <returns>The venue instance.</returns>
    Venue VenueGetById(string id);

    /// <summary>
    /// Gets the team by id.
    /// </summary>
    /// <param name="teamId">The team id.</param>
    /// <returns>Team instance.</returns>
    Team TeamGetById(string teamId);

    /// <summary>
    /// Sends the team member request.
    /// </summary>
    /// <param name="teamId">The team id.</param>
    /// <param name="message">The message.</param>
    /// <param name="userFromId">The user from id.</param>
    /// <param name="userToId">The user to id.</param>
    void TeamSendMemberRequest(string teamId, string message, string userFromId, string userToId);

    /// <summary>
    /// Handles the team request.
    /// </summary>
    /// <param name="teamRequestId">The team request id.</param>
    /// <param name="username">The username.</param>
    /// <param name="isAccepted">if set to <c>true</c> [is accepted].</param>
    void TeamHandleRequest(string teamRequestId, string username, bool isAccepted);

    /// <summary>
    /// Adds the member to team.
    /// </summary>
    /// <param name="teamId">The team id.</param>
    /// <param name="systemUserId">The system user id.</param>
    void TeamAddMemberTo(string teamId, string systemUserId);

    /// <summary>
    /// Creates the team.
    /// </summary>
    /// <param name="teamName">Name of the team.</param>
    /// <param name="description">The description.</param>
    /// <param name="dateFounded">The date founded.</param>
    void TeamCreate(string teamName, string description, DateTime dateFounded);

    /// <summary>
    /// Invites the team member.
    /// </summary>
    /// <param name="teamId">The team id.</param>
    /// <param name="inviterId">The inviter id.</param>
    /// <param name="inviteeId">The invitee id.</param>
    /// <param name="personalMessage">The personal message.</param>
    void TeamInviteMember(string teamId, string inviterId, string inviteeId, string personalMessage);

    /// <summary>
    /// Finds the name of the by.
    /// </summary>
    /// <param name="q">The query name.</param>
    /// <returns>List of found results.</returns>
    string[] TeamFindByName(string q);

    Team TeamGetByName(string name);
    /// <summary>
    /// Users the exists.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="password">The password.</param>
    /// <returns>boolena indicating if the user exists.</returns>
    bool UserExists(string username, string password);

    /// <summary>
    /// Creates the user.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="password">The password.</param>
    /// <param name="email">The email.</param>
    /// <param name="passwordQuestion">The password question.</param>
    /// <param name="passwordAnswer">The password answer.</param>
    /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
    /// <param name="providerUserKey">The provider user key.</param>
    /// <param name="status">The status.</param>
    /// <returns>Membership user instance.</returns>
    MembershipUser UserCreate(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status);

    /// <summary>
    /// Completes the registration.
    /// </summary>
    /// <param name="email">The email.</param>
    /// <param name="firstName">The first name.</param>
    /// <param name="lastName">The last name.</param>
    /// <param name="nickName">Name of the nick.</param>
    /// <param name="genderId">The gender id.</param>
    /// <param name="birthDate">The birth date.</param>
    void UserCompleteRegistration(string email, string firstName, string lastName, string nickName, string genderId, string birthDate);

    /// <summary>
    /// Emails the exists.
    /// </summary>
    /// <param name="email">The email.</param>
    /// <returns>value indicating if the email exists.</returns>
    bool UserEmailExists(string email);

    /// <summary>
    /// Gets the user by username.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <returns>The Sytem User instance.</returns>
    SystemUser UserGetByUsername(string username);

    /// <summary>
    /// Gets the user by id.
    /// </summary>
    /// <param name="id">The id of the user.</param>
    /// <returns>System user instance.</returns>
    SystemUser UserGetById(string id);

    /// <summary>
    /// Gets the user by nickname.
    /// </summary>
    /// <param name="nickname">The nickname.</param>
    /// <returns>System user instance.</returns>
    SystemUser UserGetByNickname(string nickname);

    /// <summary>
    /// Saves the user.
    /// </summary>
    /// <param name="user">The system user.</param>
    void UserSave(SystemUser user);

    /// <summary>
    /// Saves the user.list.
    /// </summary>
    /// <param name="userList">The user list.</param>
    void UserSaveList(List<SystemUser> userList);

    /// <summary>
    /// Gets the user by email address.
    /// </summary>
    /// <param name="email">The email.</param>
    /// <returns>The system user.</returns>
    SystemUser UserGetByEmail(string email);

    /// <summary>
    /// Finds the name of the by.
    /// </summary>
    /// <param name="q">The search string.</param>
    /// <returns>array of usernames found.</returns>
    string[] UserFindByName(string q);

    /// <summary>
    /// Finds the name of the by formatted user.
    /// </summary>
    /// <param name="formattedName">Formatted username "Username (nickname)".</param>
    /// <returns>System User instance.</returns>
    SystemUser UserFindByFormattedName(string formattedName);

    /// <summary>
    /// Accepts the team request.
    /// </summary>
    /// <param name="request">The team request.</param>
    /// <param name="id">The id of the request.</param>
    void TeamAcceptRequest(string request, string id);

    /// <summary>
    /// Creates and adds the venue to the users owned venues.
    /// </summary>
    /// <param name="name">The name of the venue.</param>
    /// <param name="lat">The latitude of the venue.</param>
    /// <param name="longd">The longditude of the venue.</param>
    /// <param name="desc">The description.</param>
    /// <param name="website">The website.</param>
    /// <param name="ownerId">The owner id.</param>
    /// <param name="dateFounded">The date founded.</param>
    void UserAddVenue(string name, string lat, string longd, string desc, string website, string ownerId, DateTime dateFounded);

    /// <summary>
    /// Gets the message for display.
    /// </summary>
    /// <param name="messageId">The message id.</param>
    /// <param name="user">The user object.</param>
    /// <returns>Instance of the message inbox</returns>
    MessageInbox MessageGetReceivedForDisplay(string messageId, SystemUser user);

    /// <summary>
    /// Gets the sent message for display.
    /// </summary>
    /// <param name="messageId">The message id.</param>
    /// <param name="user">The user object.</param>
    /// <returns>Message Outbox instance.</returns>
    MessageOutbox MessageGetSentForDisplay(string messageId, SystemUser user);

    /// <summary>
    /// Deletes the message.
    /// </summary>
    /// <param name="messageId">The message id.</param>
    void MessageDeleteInbox(string messageId);

    /// <summary>
    /// Deletes the outbox message.
    /// </summary>
    /// <param name="messageId">The message id.</param>
    void MessageDeleteOutbox(string messageId);

    /// <summary>
    /// Sends the team message.
    /// </summary>
    /// <param name="teamId">The team id.</param>
    /// <param name="userFromId">The user from id.</param>
    /// <param name="subject">The subject.</param>
    /// <param name="messageBody">The message body.</param>
    void MessageSend(string userToId, string userFromId, string subject, string messageBody);

    void MessageSendTeam(string teamId, string p, string title, string messageContent);

    /// <summary>
    /// Creates the league.
    /// </summary>
    /// <param name="name">The name of the team.</param>
    /// <param name="ownerId">The owner id.</param>
    /// <param name="teamSize">Size of the team.</param>
    void LeagueCreate(string name, string ownerId, int teamSize);

    /// <summary>
    /// Updates the leage.
    /// </summary>
    /// <param name="league">The league.</param>
    void LeagueUpdate(League league, SystemUser owner);

    /// <summary>
    /// Gets the league.
    /// </summary>
    /// <param name="id">The id.</param>
    /// <returns></returns>
    League LeagueGet(string id);

    /// <summary>
    /// Invites the team.
    /// </summary>
    /// <param name="team">The team.</param>
    /// <param name="league">The league.</param>
    /// <param name="message">The message.</param>
    /// <param name="host">The host.</param>
    void LeagueInviteTeamTo(Team team, League league, string message, string host);

    /// <summary>
    /// Accepts the invite.
    /// </summary>
    /// <param name="systemUser">The system user.</param>
    /// <param name="leagueId">The league id.</param>
    /// <param name="teamId">The team id.</param>
    void LeagueAcceptInvite(SystemUser systemUser, string leagueId, string teamId);

    /// <summary>
    /// Creates the league meeting.
    /// </summary>
    /// <param name="league">The league.</param>
    /// <param name="leagueMeeting">The league meeting.</param>
    void LeagueCreateMeeting(string leagueId, LeagueMeeting leagueMeeting);
  }
}
